Enterprise Objects Framework Release 1.1 Copyright ã1995 by NeXT Computer, Inc.  All Rights Reserved.

EOAssociation

Inherits From:	NSObject

Conforms To:	EOAssociationNotification

Declared In:	eointerface/EOAssociation.h

Class Description

EOAssociation is an abstract class defining the link between an EOController, which manages a collection of data-bearing enterprise objects, and a single user interface element, such as a column in an NXTableView, or a control. An EOAssociation coordinates the display and editing of property values for its controller's enterprise objects. EOAssociations can also link two controllers (see the EOQualifiedAssociation class specification for more information).

An EOAssociation links just one property of the objects supplied by its EOController to its user interface object. This property is identified by a key as used in the access layer's EOKeyValueCoding informal protocol. An association for a user interface object capable of displaying multiple enterprise objects (such as an NXTableView) displays data for all objects in the controller, while an association for a user interface object capable of displaying only one enterprise object (such as a TextField) displays data for the first selected object in the controller.

An EOAssociation is notified of changes in its controller through the EOAssociationNotification protocol. Upon receiving notice of a change, the association determines which objects it needs to display values for and sends each a valuesForKeys: message with an array containing the key for the association's property. The association then updates the user interface object with the value returned if it's different from the current value.

If the EOAssociation's user interface object changes, then the EOAssociation must send that change to its controller. EOAssociations usually set themselves up as the targets of control object so that they're notified of such changes. For example, when a user edits a TextField representing the name of an enterprise object and presses Return, the TextField sends its association an action message. The EOAssociation then gets the new value in the TextField and informs its controller that the user interface object changed by sending the controller an associationDidEdit: message. In response to this notification the controller sends a value message to the association to get the new value for the enterprise object.

For more information on how EOAssociations work with EOControllers and user interface objects, see the EOController class specification and the EOAssociationNotification protocol specification. For information on associations for a specific destination class, see one of the following class specifications:

Association Subclass	Destination Object Class

EOActionCellAssociation	Any ActionCell subclass (such as TextFieldCell)
EOBrowserAssociation	NXBrowser
EOButtonAssociation	Button
EOColumnAssociation	NXTableVector (in an NXTableView)
EOControlAssociation	See below
EOImageAssociation	NXImageView
EOMatrixAssociation	Matrix (but see below)
EOPopUpAssociation	PopUpList
EOQualifiedAssociation	EOController
EOTextAssociation	Text

EOControlAssociation can be used with any ªsimpleº control that manages a single value, such as a TextField or a Slider. However, if a control has a dedicated association subclass, you should use that. For example, Buttons should be linked with instances of EOButtonAssociation.

Note:  EOMatrixAssociation has very limited functionality. If you want to create associations with individual items in a matrix (especially with fields in a Form object), use EOActionCellAssociation.

Although the interface of any association contains only a few methods, their implementations are often highly dependent on one another and on the way the destination objects act. Because of this, if you need to create an association class for a custom user interface object class, you should create it as an immediate subclass of EOAssociation.

Instance Variables

None declared in this class.

Adopted Protocols

EOAssociationNotification	- contentsDidChange
- selectionDidChange
- discardEdits
- endEditing

Method Types

Initializing new instances	- initWithController:key:destination:

Getting association members	- controller
- destination

Getting the key and value	- key
- value

Instance Methods

controller

- (EOController *)controller

Returns the EOController responsible for the association.

destination

- destination

Returns the object that the association monitors. This is typically a user interface object, but doesn't have to be.

initWithController:key:destination:

- initWithController:(EOController *)aController
key:(NSString *)aKey
destination:destination

Initializes a newly allocated EOAssociation with aController. aKey is the name of the property represented by the association, and is used as the identifier for value transfers to and from destination (typically a user interface object or another EOController). This is the designated initializer for the EOAssociation class. Returns self.

See also:  - addAssociation: (EOController)

key

- (NSString *)key

Returns the name of the property that the association transfers to and from its destination.

value

- value

Returns the value of the association's destination as an instance of an appropriate value class (see ªMapping from Database to Objectsº in the access layer's EOAttribute class specification). For example, the value class for a TextField's value is NSString.

For applications using the access layer, if the value class specified for an enterprise object's attribute in the EOModel isn't NSString or NSData, it must match exactly the value class used by the association.

See also:  - key, - takeValuesFromDictionary: (EOKeyValueCoding informal protocol)